package edu.nyu.hps.assignment4;

public class People implements Comparable<People> {
	int x, y, rescueTime, index, timesSurvived, origRescueTime;
	boolean isSaved;
	Hospital h;

	public People(int x, int y, int rtime, int index) {
		this.x = x;
		this.y = y;
		this.rescueTime = rtime;
		this.origRescueTime = rtime;
		this.index = index;
		this.isSaved = false;
		this.timesSurvived = 0;
	}
	
	public int compareTo(People o) {
//		if (rescueTime < o.rescueTime) {
//			return -1;
//		} else if (rescueTime == o.rescueTime) {
//			return 0;
//		}
//		return 1;
//		
//		if(h.density==o.h.density)	return rescueTime == o.rescueTime ? 0 : (rescueTime<o.rescueTime ? -1 : 1);
//		return h.density<o.h.density ? -1 : 1;
//		
//		if(rescueTime==o.rescueTime) return h.density == o.h.density ? 0 : (h.density<o.h.density ? -1 : 1);
//		return rescueTime< o.rescueTime ? -1 : 1;
		
//		if(rescueTime==o.rescueTime) return timesSurvived == o.timesSurvived ? 0 : (timesSurvived < o.timesSurvived ? 1 : -1);
//		return rescueTime< o.rescueTime ? -1 : 1;
		
		if(timesSurvived == o.timesSurvived) return rescueTime==o.rescueTime ? 0 : (rescueTime< o.rescueTime ? -1 : 1);
		return timesSurvived < o.timesSurvived ? 1 : -1;
		
//		int valThis = (1-prob)*rescueTime + (1-prob)*dist(this);
//		int valo = prob*o.rescueTime + prob*dist(o);
//		
//		if( valThis == valo) return 0; 
//		else if(valThis<valo) return -1;
//		return 1;
		
//		if(rescueTime==o.rescueTime) return dist(this) == dist(o) ? 0 : (dist(this) < dist(o) ? -1 : 1);
//		return rescueTime< o.rescueTime ? -1 : 1; 
	}
	
	public int dist(People p){
		return (Math.abs(p.h.x - p.x) + Math.abs(p.h.y - p.y));
	}	


}
